package com.sskj.mine.http;
import com.sskj.mine.asset.data.AddressListBean;
import com.sskj.mine.asset.data.AddressListBean;
import com.sskj.mine.account.data.AccountBean;
import com.sskj.mine.asset.data.AssetMainBean;
import com.sskj.mine.asset.data.RechargeBean;
import com.sskj.mine.asset.data.RechargeTypeBean;
import com.sskj.mine.asset.data.WithdrawConfigBean;
import com.lzy.okgo.request.GetRequest;
import com.sskj.mine.asset.data.BillBean;
import com.sskj.mine.asset.data.CoinTypeBean;


import com.lzy.okgo.OkGo;
import com.lzy.okgo.request.PostRequest;
import com.sskj.common.base.HttpData;
import com.sskj.lib.bean.PageBean;
import com.sskj.mine.asset.data.AssetBean;
import com.sskj.mine.asset.data.ExchangeConfigBean;
import com.sskj.mine.asset.data.ExchangeRecordsBean;
import com.sskj.mine.asset.data.RecordsBean;
import com.sskj.mine.bean.NodeBean;

import java.util.List;
import java.util.Map;

/**
 * 作者 :吕志豪
 * 简书：https://www.jianshu.com/u/6e525b929aac
 * github：https://github.com/lvzhihao100
 * 描述：
 * 创建时间：2018-10-15 14:08
 */
public class HttpService {

    public PostRequest<HttpData<Object>> verifyFirst( String name, String idCard) {
        return OkGo.<HttpData<Object>>post(HttpConfig.BASE_URL + HttpConfig.Verify_FISRT)
                .params("realname", name)
                .params("card_num", idCard);
    }



    /**
     * 资产管理 首页
     *

     * @return
     */
    public PostRequest<HttpData<PageBean<AssetBean>>> getAssetMainList(){
        return OkGo.<HttpData<PageBean<AssetBean>>>post(HttpConfig.BASE_URL + HttpConfig.GET_ASSET)
            ;
    }
    /**
     * 资产管理 首页
     *

     * @return
     */
    public PostRequest<HttpData<AssetMainBean>> getAssetMain(){
        return OkGo.<HttpData<AssetMainBean>>post(HttpConfig.BASE_URL + HttpConfig.GET_ASSET)
                ;
    }

    /**
     * 币种类型 (筛选用)
     *
     * @return
     */
    public GetRequest<HttpData<List<CoinTypeBean>>> getAssetType(){
        return OkGo.<HttpData<List<CoinTypeBean>>>get(HttpConfig.BASE_URL + HttpConfig.GET_ASSET_TYPE);
    }
    /**
     * 账单类型 (筛选用)
     *
     * @return
     */
    public GetRequest<HttpData<Map<String,String>>> getRecordType(){
        return OkGo.<HttpData<Map<String,String>>>get(HttpConfig.BASE_URL + HttpConfig.GET_RECORD_TYPE);
    }

    /**
     * 充值/提币记录
     *
     * @param type recharge 充值 cash 提币
     * @param pid 币种id
     * @return
     */
    public GetRequest<HttpData<PageBean<RecordsBean>>> getAssetRecord(String type, String pid){
        return OkGo.<HttpData<PageBean<RecordsBean>>>get(HttpConfig.BASE_URL + HttpConfig.GET_ASSET_RECORD)
                .params("type", type)
                .params("pid", pid);
    }

    /**
     * 资产流水 账单
     *
     * @param wall_type \t财务类型
     * @param pid 币种id
     * @return
     */
    public GetRequest<HttpData<PageBean<BillBean>>> getAssetRecordAll(String p,String size,String wall_type, String pid){
        return OkGo.<HttpData<PageBean<BillBean>>>get(HttpConfig.BASE_URL + HttpConfig.GET_ASSET_RECORD_ALL)
                .params("p", p)
                .params("size", size)
                .params("wall_type", wall_type)
                .params("pid", pid);
    }

    /**
     * 兑换页面
     *
     * @param type 1代币兑usdt 2 usdt兑换代币
     * @return
     */
    public PostRequest<HttpData<ExchangeConfigBean>> getExchangeConfig(String type){
        return OkGo.<HttpData<ExchangeConfigBean>>post(HttpConfig.BASE_URL + HttpConfig.GET_EXCHANGE_CONFIG)
                .params("type", type);
    }

    /**
     * 确认兑换
     *
     * @param type 1代币兑usdt 2 usdt兑换代币
     * @param num 兑换数量
     * @param tpwd 交易密码
     * @return
     */
    public PostRequest<HttpData> cash(String type,String num,String tpwd){
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.CASH)
                .params("type", type)
                .params("num", num)
                .params("tpwd", tpwd);
    }

    /**
     * 兑换记录
     *
     * @param p 页码，默认1
     * @param size 页条数，默认5
     * @return
     */
    public PostRequest<HttpData<PageBean<ExchangeRecordsBean>>> getCashRecord(String p, String size){
        return OkGo.<HttpData<PageBean<ExchangeRecordsBean>>>post(HttpConfig.BASE_URL + HttpConfig.GET_CASH_RECORD)
                .params("p", p)
                .params("size", size);
    }

    /**
     * 提币页面
     *
     * @param pid 币种ID
     * @return
     */
    public GetRequest<HttpData<WithdrawConfigBean>> getWithdrawConfig(String pid){
        return OkGo.<HttpData<WithdrawConfigBean>>get(HttpConfig.BASE_URL + HttpConfig.GET_WITHDRAW_CONFIG)
                .params("pid", pid);
    }
    /**
     * 发送验证码（注册）
     *
     * @param mobile 手机号
     * @param type   1注册 （2 重置 3 安全验证 4 交易密码设置 5 提币）
     * @return
     */
    public GetRequest<HttpData> sendSms(String mobile, String type) {
        return OkGo.<HttpData>get(HttpConfig.BASE_URL + HttpConfig.SEND_SMS)
                .params("mobile", mobile)
                .params("type", type);
    }

    /**
     * 提币
     *
     * @param num 数量
     * @param pid 币id
     * @param tpwd 交易密码
     * @param code code
     * @param account 手机号/邮箱号
     * @param address 地址
     * @return
     */
    public PostRequest<HttpData> withdraw(String num,String pid,String tpwd,String code,String account,String address){
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.WITHDRAW)
                .params("num", num)
                .params("pid", pid)
                .params("tpwd", tpwd)
                .params("code", code)
                .params("account", account)
                .params("address", address);
    }

    /**
     * 币充值页面
     *
     * @param coin_type 币种类型（可充值列表接口返回的类型）
     * @return
     */
    public GetRequest<HttpData<RechargeBean>> recharge(String coin_type){
        return OkGo.<HttpData<RechargeBean>>get(HttpConfig.BASE_URL + HttpConfig.RECHARGE)
                .params("coin_type", coin_type);
    }


    /**
     * 币充值页面
     *
     * @return
     */
    public GetRequest<HttpData<List<RechargeTypeBean>>> rechargeList(){
        return OkGo.<HttpData<List<RechargeTypeBean>>>get(HttpConfig.BASE_URL + HttpConfig.RECHARGE_LIST);
    }

    /**
     * 币充值页面
     *
     * @return
     */
    public GetRequest<HttpData<List<RechargeTypeBean>>> withdrawList(){
        return OkGo.<HttpData<List<RechargeTypeBean>>>get(HttpConfig.BASE_URL + HttpConfig.WITHDRAW_LIST);
    }

    /**
     * 站内转账
     *
     * @param price 数量
     * @param pid 币id
     * @param tpwd 交易密码
     * @param ouid 用户ID
     * @return
     */
    public PostRequest<HttpData> transfer(String price,String pid,String tpwd,String ouid){
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.TRANSFER)
                .params("price", price)
                .params("pid", pid)
                .params("tpwd", tpwd)
                .params("ouid", ouid);
    }

    /**
     * 转账流水记录
     *
     * @return
     */
    public GetRequest<HttpData<PageBean<AccountBean>>> transferRecord(){
        return OkGo.<HttpData<PageBean<AccountBean>>>get(HttpConfig.BASE_URL + HttpConfig.TRANSFER_RECORD);
    }


    /**
     * 提币地址添加删除
     *
     * @param address 钱包地址
     * @param act 操作类型，删除 del, 添加不用这个参数
     * @param notes 备注
     * @param type 1btc(usdt) 2eth
     * @return
     */
    public PostRequest<HttpData> addAddress(String address,String act,String notes,String type,String id){
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.ADD_ADDRESS)
                .params("address", address)
                .params("act", act)
                .params("id", id)
                .params("notes", notes)
                .params("coin_type", type);
    }

    /**
     * 提币地址列表
     *
     * @return
     */
    public GetRequest<HttpData<AddressListBean>> addressList(){
        return OkGo.<HttpData<AddressListBean>>get(HttpConfig.BASE_URL + HttpConfig.ADDRESS_LIST);
    }


    public PostRequest<HttpData<PageBean<NodeBean>>> getNode(String page, String size) {
        return OkGo.<HttpData<PageBean<NodeBean>>>post(HttpConfig.BASE_URL + HttpConfig.GET_NODE)
                .params("P", page)
                .params("size", size);
    }
}